package com.zsummer.zero.design.create.factory;

/**
 * 简单工厂模式
 * @author zhouyujiang
 *
 */
public class Demo1 {

	public static void main(String[] args) {
		Person boy = new PersonFactory().createPerson("boy");
		boy.say();
		Person girl = new PersonFactory().createPerson("girl");
		girl.say();
	}
	
}

class PersonFactory {
	
	public  Person createPerson(String string) {
		if ("boy".equals(string)) {
			return new Boy();
		}
		if ("girl".equals(string)) {
			return new Girl();
		}
		throw new RuntimeException("不支持的类型");
	}
}
